﻿using UnityEngine;
using System.Collections;

public class ConvertFacepassStrToClass : MonoBehaviour {





	static public T[] FacepassStringToClasses<T>(string facePassStr) where T : class
	{
		string StrForJsonParseByBrackets=GetFacePassJsonDatas(facePassStr);
		return	ReadFileTool.JsonToClasses<T>(StrForJsonParseByBrackets);
	}


	static public  string GetFacePassJsonDatas(string facePassOrigStr)
	{
		int beginIdxBracket=	facePassOrigStr.IndexOf("[");
		int endIdxBracket= facePassOrigStr.LastIndexOf("]");
		
		if((beginIdxBracket<0)||(endIdxBracket<0))
		{
			Debug.LogError("No bracket found");
			return string.Empty;
		}
		
		if(!(endIdxBracket>beginIdxBracket))
		{
			Debug.LogError("after bracket is not after the fore bracket");
			return string.Empty;
		}
		
		return facePassOrigStr.Substring(beginIdxBracket,endIdxBracket-beginIdxBracket+1);
		
	}


}
